package com.financing.wap.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.financing.wap.dao.IAccountDao;
import com.financing.wap.dao.ICorpDao;
import com.financing.wap.dto.AccountCorpDTO;
import com.financing.wap.dto.CompanyInvitationCodeDTO;
import com.financing.wap.dto.CorpDeptDTO;
import com.financing.wap.dto.CorpFaUserDTO;
import com.financing.wap.service.ICorpService;
import com.financing.wap.vo.CorpDeptVO;
import com.financing.wap.vo.CorpFaUserVO;


@Service("corpService")
public class CorpServiceImpl implements ICorpService{

	@Autowired
	private ICorpDao corpDao;
	
	@Autowired
	private IAccountDao accountDao;
	
	@Override
	public String addCorpFaUser(CorpFaUserDTO dto) {

		String userId = corpDao.addCorpFaUser(dto);
		AccountCorpDTO accountCorp = new AccountCorpDTO();
		accountCorp.setUserId(userId);
		accountCorp.setCreateBy(dto.getuManagerId().toString());
		accountCorp.setUpdateBy(dto.getuManagerId().toString());
		accountDao.addAccount(accountCorp);
		
		return userId;
	}

	@Override
	public List<CorpFaUserDTO> getCorpUserFaList(CorpFaUserVO vo) {
		return corpDao.getCorpUserFaList(vo);
	}

	@Override
	public List<CorpDeptDTO> getCorpDeptList(CorpDeptVO vo) {
		return corpDao.getCorpDeptList(vo);
	}

	@Override
	public Integer insertCorpDept(CorpDeptDTO dto) {
		return corpDao.insertCorpDept(dto);
	}

	@Override
	public Integer updateCorpDept(CorpDeptDTO dto) {
		return corpDao.updateCorpDeptList(dto);
	}

	@Override
	public CorpDeptDTO getCorpDeptViewById(CorpDeptVO vo) {
		return corpDao.getCorpDeptViewById(vo);
	}

	@Override
	public Integer getCorpUserFaCount(CorpFaUserVO vo) {
		return corpDao.getCorpUserFaCount(vo);
	}

	@Override
	public CorpFaUserDTO getCorpUserFaView(CorpFaUserVO vo) {
		return corpDao.getCorpUserFaView(vo);
	}

	@Override
	public String getInvitationCode(CompanyInvitationCodeDTO cic) {
		cic = corpDao.getCorpInvitationCode(cic);
		if(cic != null){
			return cic.getCompanyInvitationCode();
		}
		return "";
	}
	
	

}
